<template>

  <div class="app-wrapper " :class="{hideSidebar:hideSidebar}">
    <div class="navbar">
      <div class="main-title" @click="backToDash">双凤镇企业用地租赁分级管理平台</div>
      <div class="text-gray back-btn" @click="backToDash">后退</div>
    </div>
    <div class="map-sidebar">
      <el-scrollbar wrap-class="scrollbar-wrapper">
        <div class="company-list-wrapper">


          <!--表格渲染-->

          <div>
            <div class="houseInfo">
              <h3>厂房信息</h3>
              <p>企业名称：{{houseInfo.enterpriseName}}</p>
              <p>厂房面积：{{houseInfo.厂房面积	}}</p>
              <p>所属网格：{{houseInfo.grid	}}</p>
              <p >联系电话：{{houseInfo.contactPhone}}</p>
              <h4>租赁企业列表</h4>
            </div>


            <a class="company-panel" v-for="item in companyList" :href="'/business/enterprise/detail/' + item.id" target="_blank">
                <div class="img-wrapper">

                  <img class="cover-img" v-if="item.photoFileList.length" :src="`/sf_landuse-service/data/upload/${item.photoFileList[0].filePath}`" alt="">
                </div>
                <div class="info-wrapper">
                  <p class="title fz-20 text-dark">{{ item.enterpriseName }}</p>
                  <p class="fz-16 text-gray">联系电话：{{item.contactPhone}}</p>
                  <p class="fz-16 text-gray">占用厂房面积	：{{item.leaseArea}}</p>
                </div>
            </a>
          </div>
        </div>


      </el-scrollbar>
      <div class="sidebar-toggler" @click="toggleSidebar()"></div>
    </div>
    <div class="map-main-container">
      <amap @click="showCompany" />

    </div>

  </div>

</template>

<script>
import Amap from './map.vue'

export default {
  name: 'Map',
  components: {
    Amap
  },
  // 数据字典

  data() {
    return {
      permission: {
        add: [],
        edit: [],
        del: [],
        info: []
      },
      landlordId: null,
      hideSidebar:true,
      companyList:[],
      houseInfo: {},
    }
  },
  methods: {
    backToDash() {
      this.$router.push('/dashboard')
    },
    toggleSidebar(){
      this.hideSidebar=!this.hideSidebar;
    },
    showCompany(item){
      this.houseInfo=item;
      console.log(item)
      this.companyList=item.houseLesseeList;
      if(this.companyList.length){
        if(this.hideSidebar){
          this.hideSidebar=false
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.main-title {
  font-size: 18px;
  line-height: 80px;
  margin-left: 100px;
  cursor: pointer;
  display: inline-block;
}
.back-btn{
  margin-right:50px;
  float:right;
  line-height:80px;
  cursor: pointer;
}

.navbar {
  height: 80px;
  background: #FFFFFF;
  box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.5);
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 2;
}

@import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss";

.app-wrapper {
  @include clearfix;
  position: relative;
  height: 100%;
  width: 100%;
}

.map-sidebar {
  transition: width 0.28s;
  width: 600px !important;
  background: #FFFFFF;
  box-shadow: 2px 10px 4px 0px rgba(193, 193, 193, 0.5);
  height: 100%;
  position: fixed;
  font-size: 0;
  top: 0;
  bottom: 0;
  left: 0;
  z-index:1;



  ::v-deep.scrollbar-wrapper {
    overflow-x: hidden !important;
  }

  .el-scrollbar__bar.is-vertical {
    right: 0;
  }

  .el-scrollbar {
    height: 100%;
  }
  .sidebar-toggler{
    position: absolute;
    top: 50%;
    right: -16px;
    width: 16px;
    height: 56px;
    font-size: 16px;
    line-height: 56px;
    text-align: center;
    background: #fff;
    border: 1px solid #dbdbdb;
    border-left: none;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    box-shadow: 2px 2px 4px #999;
    cursor: pointer;
    z-index:1;
    &:after{
      content:"<"
    }
  }
}


.hideSidebar {
  .houseInfo{
    display: none;
  }
  .company-panel{
    display: none;
  }
  .map-sidebar{
    width:54px !important;

  }
  .map-main-container{
    margin-left: 54px;

  }
  .sidebar-toggler:after{
    content:">"
  }
}
.company-list-wrapper {
  padding: 20px;
  padding-top: 100px;
  height: 100%;
  width: 100% !important;
  font-size: 14px;
}

.map-main-container {
  min-height: 100vh;
  padding-top:80px;
  transition: margin-left 0.28s;
  margin-left: 600px;
  position: relative;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.company-panel {
  display: flex;
  margin-bottom:20px;
  padding-bottom:20px;
  border-bottom: 1px solid #DDDDDD;
  .title{
    margin-top:0;
  }

  .img-wrapper {
    width: 200px;
    height: 120px;


  }
  .info-wrapper{
    padding:20px;
    padding-top:0;
    flex:1;
  }
}
.fz-16{
  font-size: 16px;
}
.fz-20{
  font-size: 20px;
}
.text-dark{
  color: #333333;

}
.text-gray{
  color: #999999;

}
</style>
